#!/bin/sh
echo $0 $*
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
# GAMEDIR=${PWD}
GAMEDIR="/mnt/SDCARD/Ports/hcl"
echo ==========GAMEDIR is $GAMEDIR
controlfolder="../PortMaster"

source $controlfolder/control.txt
#source $controlfolder/tasksetter

get_controls

exec > >(tee "$GAMEDIR/log.txt") 2>&1

$ESUDO chmod 666 /dev/tty1


$ESUDO rm -rf ~/.hydracastlelabyrinth
ln -sfv $GAMEDIR/conf/.hydracastlelabyrinth ~/

cd $GAMEDIR
$ESUDO $controlfolder/oga_controls hcl $param_device &
SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig" ./hcl 2>&1 | tee $GAMEDIR/log.txt
$ESUDO kill -9 $(pidof oga_controls)
$ESUDO systemctl restart oga_events &
printf "\033c" >> /dev/tty1